﻿<%@ Page Language="C#" AutoEventWireup="true" EnableSessionState="True" %>

<%@ Register TagPrefix="Hi" Namespace="Hidistro.UI.SaleSystem.Tags" Assembly="Hidistro.UI.SaleSystem.Tags" %>
<%@ Register TagPrefix="Hi" Namespace="Hidistro.UI.Common.Controls" Assembly="Hidistro.UI.Common.Controls" %>
<%@ Register TagPrefix="wnxd" Namespace="wnxd.Web" Assembly="wnxd.Web" %>
<%@ Import Namespace="Hidistro.Entities.Sales" %>
<%@ Import Namespace="Hidistro.SaleSystem.Shopping" %>
<%@ Import Namespace="Hidistro.Entities.Orders" %>
<%@ Import Namespace="Hidistro.Messages" %>
<%@ Import Namespace="Hidistro.Membership.Context" %>
<%@ Import Namespace="Hidistro.Core" %>
<%@ Import Namespace="Hidistro.Membership.Core" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="Hidistro.Entities" %>
<%@ Import Namespace="wnxd.javascript" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="Hidistro.SaleSystem.Catalog" %>
<%@ Import Namespace="Hidistro.Entities.Promotions" %>
<%@ Import Namespace="Hidistro.SqlDal.Sales" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
	<meta name="apple-touch-fullscreen" content="YES"/>
	<meta name="apple-mobile-web-app-capable" content="yes" />
	<meta name="format-detection" content="telephone=no"/>
	<link rel="stylesheet" type="text/css" href="http://res.juseshop.com/css/huodong/mianfeiyangshi.css"/>
    <script src="http://res.juseshop.com/utility/jquery-1.6.4.min.js"></script>
</head>
<body>
    <wnxd:Web runat="server"></wnxd:Web>
    <div class="w320 clearfix">
        <div class="mfdl">
            <img src="http://image.juseshop.com/images/huodong/mianfei/mflq1.jpg">
            <img src="http://image.juseshop.com/images/huodong/mianfei/mflq2.jpg">
            <p class="dw1">您仅需承担的成本费用：</p>
            <p class="dw2"><em>快递费：10元</em><em>材料费：36元</em><br><em>包装费：2元</em></p>
            <p class="dw3">合计：48元</p>
        </div>
        

       <div class="mfdl1">
                <%--<a prefix="wnxd_Ajax" inc="aspnetForm" url="/huodong/SpreadPageOrder_weiku.aspx" onclick="Post" callback="CallBack" repeat="Repeat" act="form" style="cursor: pointer;">确认支付</a>--%>
                <input name="" type="button" value="确认支付" onclick="return paySelect(this)" />
            </div>

    </div>

    <script>
        //获取URl参数
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
        function paySelect(obj) {
            $.post(location.href, "wnxd_Ajax=btnPays&type=2&orderid=" + getQueryString("orderid"), function (e) {
                //location.href = e.url;
                location.href = "/FinishOrder.aspx?orderId=" + getQueryString("orderid");
            });
        }
    </script>
</body>
</html>
<script runat="server">
    protected json btnPays()
    {
        Juse.Interface.UserOrder uo = new Juse.Interface.UserOrder();
        string orderId = Request["orderid"].ToString();
        string type = Request["type"].ToString();
       
        //int result = 0;
        //int.TryParse(type, out result);
        //PaymentModeInfo paymentMode = uo.GetPaymentMode(result);
        //if (paymentMode != null)
        //{
        //    JSShop.Model.Hishop_Orders orderInfo = uo.GetModelByOrderId(orderId);
        //    orderInfo.PaymentTypeId = paymentMode.ModeId;
        //    orderInfo.Gateway = paymentMode.Gateway;
        //    orderInfo.PaymentType = paymentMode.Name;
        //    uo.UpdateByModel(orderInfo);
        //}
        JSShop.Model.Hishop_Orders orderInfo = uo.GetModelByOrderId(orderId);
        orderInfo.PaymentTypeId = int.Parse(type);
        orderInfo.Gateway = "hishop.plugins.payment.alipaydirect.directrequest";
        orderInfo.PaymentType = "支付宝";
        uo.UpdateByModel(orderInfo);

        return new json(new { url = "/FinishOrder.aspx?orderId=" + orderId });
        //return new json(new { url = ConfigurationManager.AppSettings["PayUrl"].ToString() + "/FinishOrder.aspx?orderId=" + orderId });
    }
</script>
